<?php 
	class portofolio_model extends CI_model{
		
		function get_portofolio($id_language, $limit, $offset){
			$q = $this->db->query("SELECT p.id_portofolio, p.date_project, p.id_kategori_sub, ksl.nama_kategori_sub, p.url_gambar_portofolio, pl.judul_portofolio, pl.content_portofolio, DATE_FORMAT(p.date_update,'%d %b %Y') as 'date_update' 
								   FROM
								   setting s
								   JOIN
								   kategori_sub ks ON s.id_table=ks.id_kategori
								   JOIN
								   kategori_sub_language ksl ON ks.id_kategori_sub=ksl.id_kategori_sub
								   JOIN
								   portofolio p ON ks.id_kategori_sub=p.id_kategori_sub
								   JOIN
								   portofolio_language pl ON p.id_portofolio=pl.id_portofolio
								   WHERE
								   s.key='portofolio' AND pl.id_language=$id_language
								   ORDER BY p.date_project DESC LIMIT $offset, $limit");

			return $q->result();
		}

		function get_portofolio_view($id_language, $id){
			$q = $this->db->query("SELECT p.id_portofolio, DATE_FORMAT(p.date_project,'%d %b %Y') as 'date_project', p.id_kategori_sub, ksl.nama_kategori_sub, p.url_gambar_portofolio, pl.judul_portofolio, pl.content_portofolio, DATE_FORMAT(p.date_update,'%d %b %Y') as 'date_update' 
								   FROM
								   setting s
								   JOIN
								   kategori_sub ks ON s.id_table=ks.id_kategori
								   JOIN
								   kategori_sub_language ksl ON ks.id_kategori_sub=ksl.id_kategori_sub
								   JOIN
								   portofolio p ON ks.id_kategori_sub=p.id_kategori_sub
								   JOIN
								   portofolio_language pl ON p.id_portofolio=pl.id_portofolio
								   WHERE
								   s.key='portofolio' AND pl.id_language=$id_language
								   AND p.id_portofolio=$id");

			return $q->result();
		}

		function get_portofolio_rows($id_language){
			$q = $this->db->query("SELECT * 
								   FROM
								   setting s
								   JOIN
								   kategori_sub ks ON s.id_table=ks.id_kategori
								   JOIN
								   kategori_sub_language ksl ON ks.id_kategori_sub=ksl.id_kategori_sub
								   JOIN
								   portofolio p ON ks.id_kategori_sub=p.id_kategori_sub
								   JOIN
								   portofolio_language pl ON p.id_portofolio=pl.id_portofolio
								   WHERE
								   s.key='portofolio' AND pl.id_language=$id_language");

			return $q->num_rows();
		}

	}

?>